#include "stdinc.h"
#include "SettingsPage.h"


SettingsPage::SettingsPage(HINSTANCE hInst, void* cfg) : hInstance(hInst), config(cfg), hWndComboBox(NULL), hwndText(NULL)
{
}


SettingsPage::~SettingsPage(void)
{
}

void 
SettingsPage::Create(HWND parent)
{
	hWndComboBox = CreateWindow(L"STATIC",
                                        L"Id bota:",
										WS_CHILD | WS_VISIBLE | WS_TABSTOP | SS_CENTER,
                                        200, 70, 200, 50,
                                        parent,
                                        NULL,
										hInstance,
                                        NULL);
	hwndText = CreateWindow(
                               L"edit",                              // The class name required is edit
                               L"",                                 // Default text.
                               WS_VISIBLE | WS_CHILD | WS_BORDER, // the styles
                               400,100,                                      // the left and top co-ordinates
                               200,50,                                  // width and height
                               parent,                                     // parent window handle
                               NULL,                         // the ID of your combobox
                               hInstance,                                // the instance of your application
                               NULL
                            );       
	wchar_t* botId;
	wtwGetStr(wtw, config, L"botID", L"d304312c4e342d88", &botId); 
	HFONT police = CreateFont(16, 0, 0, 0, 400, 0, 0, 0, 0, 0, 0, 0, 0, L"Arial");
	SendMessage(hwndText,WM_SETTEXT, (WPARAM)0, (LPARAM)botId);
	SendMessage(hwndText,WM_SETFONT, (WPARAM)police, (LPARAM)0);
	SendMessage(hWndComboBox,WM_SETFONT, (WPARAM)police, (LPARAM)0);

	free(botId);
};

void 
SettingsPage::GetClientRect(RECT* rc)
{
	rc->bottom = 0;
	rc->left = 0;
	rc->right=100;
	rc->top=100;
};

void 
SettingsPage::SetScrollSize(int width, int height)
{
	
};

void 
SettingsPage::MoveWindow(int x, int y, int cx, int cy, bool b)
{
	::MoveWindow(hWndComboBox,x+10,y+10,100,25,b);
	::MoveWindow(hwndText,x+100,y+9,150,22,b);
};

void 
SettingsPage::ShowWindow(int command)
{
	::ShowWindow(hwndText, command);
	::ShowWindow(hWndComboBox, command);
};

void 
SettingsPage::close(bool b)
{
	if(b){
	    LRESULT iTextSize = SendMessage(hwndText, EM_GETLIMITTEXT, 0, 0);
        wchar_t* szText = new wchar_t[iTextSize];
        SendMessage(hwndText, WM_GETTEXT, iTextSize, (LPARAM)szText);
		wtwSetStr(wtw, config,L"botID", szText);
		delete szText;
	}
	::CloseWindow(hWndComboBox);
	::CloseWindow(hwndText);
};

void 
SettingsPage::DestroyWindow()
{
	::DestroyWindow(hWndComboBox);
	::DestroyWindow(hwndText);
};